package com.ludomancy.archeologyrpg.entities;

import java.awt.Graphics;
import java.awt.Point;

import com.ludomancy.archeologyrpg.GameTheme;
import com.ludomancy.archeologyrpg.Entity;
import com.ludomancy.archeologyrpg.Game;

public class OxygenTank extends Entity
{
	private static final int recoveryTime = Game.discretize(4000);
	private int currentTimeToRecover = 0;
	
	public OxygenTank(Point p)
	{
		super(p);
	}

	public void paint(Graphics g, int x, int y)
	{
		paintDefaultIcon(g, OXYGEN, x, y);
	}
	
	public void update(boolean running, boolean activated)
	{
		if(running)
		{
			if(activated)
			{
				currentTimeToRecover ++;
				if(currentTimeToRecover >= recoveryTime)
				{
					currentTimeToRecover = recoveryTime;
					dead = true;
					Game.game.rocket.oxygenTime = Game.game.rocket.maxOxygenTime;
				}
			}
		}
	}

	public void paintInfo(Graphics g)
	{
		g.setColor(GameTheme.theme.getDefaultTextColor());
		g.setFont(GameTheme.theme.tinyFont);
		if(currentTimeToRecover > 0)
		{
			GameTheme.theme.paintBar(g, px, py+Game.ENTITY_TILE_SIZE, currentTimeToRecover, recoveryTime);
		}
	}

	public String getActionVerb()
	{
		return "Recover";
	}
}
